import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

const actionTypes = [
  {
    type: 'text',
    name: '输入'
  },
  {
    type: 'click',
    name: '点击'
  },
  {
    type: 'clear',
    name: '清除'
  },
  {
    type: 'contains',
    name: '检查页面元素'
  },
  {
    type: 'wait',
    name: '等待'
  },
  {
    type: 'should',
    name: 'should'
  },
  {
    type: 'trigger',
    name: 'trigger'
  },
  {
    type: 'visit',
    name: '访问url'
  },
  // {
  //   type: 'select',
  //   name: 'select'
  // },
  // {
  //   type: 'table',
  //   name: 'table'
  // },
];

async function main() {
  // 初始化操作类型表
  await prisma.actionTypes.deleteMany();
  for (let actType of actionTypes) {
    await prisma.actionTypes.create({
      data: actType
    });
  }
}

main().catch((e) => {
  console.log(e);
  process.exit(1);
}).finally(async () => {
  // 执行完后关闭数据库
  await prisma.$disconnect();
});